var  app = getApp();

Page({ 
    /**
     * 页面的初始数据
     */
    data: {        
        autoplay: true,
        typeValue: null,
        showRightToast: false,
        changeImg: false,
        show: true,
        
        played: false,
        //滑动触点开始的时候
        startPoint: 0,
        currentImageIndex: 0,
        swiperH:'',//swiper高度
         nowIdx:0,//当前swiper索引
         rent:0,
         city_hidden:false,
         status:0
 
    },
 
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      let that=this;
 
    var open=wx.getStorageSync('open');   
  
  
       
      that.setData({
        platform:app.globalData.platform,

        open:open,
         width:app.globalData.windowWidth,
        height:app.globalData.windowHeight,
        statusBarHeight:app.globalData.statusBarHeight,
        navHeight:app.globalData.navHeight,
        marginTop:app.globalData.navTitleTop,
        domain:app.globalData.domain,
        appUrl:app.globalData.appUrl
      })
    },
    
    getNotice:function(){
      var open=wx.getStorageSync('open');      
      var member_id=open.member_id;
      let that=this;
      wx.request({
        url:app.globalData.domain + 'member/notice/getLastNotice',
        data:{open_id:open.id,member_id:member_id,form:5},
        success:res=>{
          console.log(res);
          that.setData({
            notice:res.data.notice
          })
        }
      })
    },
    getIndex:function(){
      //var open=wx.getStorageSync('open');
      
     // var member_id=open.member_id;
      let that=this;
      wx.request({
        url:app.globalData.appUrl + 'defaults/getIndex',
        data:{form:'index'},
        success:res=>{
          console.log(res);
          var data=res.data;
          that.setData({
            list:data.list,
            navList:data.navList,
            swiperList:data.swiperList,
          })
        }
      })
    },
    getList:function(e){
            console.log(e);
            let data=this.data;
            var now=data.status;
            var status = e.currentTarget.dataset.status;
            if(status==now){
    
            }else{
                this.setData({
                    status:status
                })
            }
        },  
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
 
    },
 
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        //   wx.hideLoading();
   
        this.getNotice(); 
        this.getIndex(); 
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
 
    },
 
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
 
    },
 
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
 
    },
 
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
 
    },
 
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
 
    },
    
   getHeight:function(e){
      var winWid = wx.getSystemInfoSync().windowWidth - 2*50;//获取当前屏幕的宽度
      var imgh = e.detail.height;//图片高度
      var imgw = e.detail.width;
      var sH = winWid * imgh / imgw + "px"
      this.setData({
          swiperH: sH//设置高度
      })
  },
  getTruckHeight:function(e){
    console.log(e);
    var winWid = 300;//获取当前屏幕的宽度
    var imgh = e.detail.height;//图片高度
    var imgw = e.detail.width;
    var sH = winWid * imgh / imgw + "rpx"
    this.setData({
        truckrH: sH//设置高度
    })
},
  //swiper滑动事件
  swiperChange:function(e){
   // console.log(e.detail.current);
      this.setData({
          nowIdx: e.detail.current
      })
  },
  fn:function(e){
    congsole.log(e);
  },
  goto:function(e){
      console.log(e);
      var active=e.currentTarget.dataset.active;
      var url=e.currentTarget.dataset.url;
      if(active=='index'){
          if(url!="#"){
        wx.reLaunch({
          url: url,
        })
       }
      }else{
        if(url!="#"){
        wx.navigateTo({
           url: url,
        })
      }
    }
  },
  onRefresh: function() {
      this.onLoad()
      //this.onReady()
    }

})
